package com.example.newsapp.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.newsapp.model.entity.User;
import com.example.newsapp.model.repository.UserRepository;

public class UserViewModel extends AndroidViewModel {
    private UserRepository repository;
    private LiveData<User> loginResult;
    private LiveData<String> registerResult;

    public UserViewModel(@NonNull Application application) {
        super(application);
        repository = new UserRepository(application);
        loginResult = repository.getLoginResult();
        registerResult = repository.getRegisterResult();
    }

    public void login(String username, String password) {
        repository.login(username, password);
    }

    public void register(String username, String password, String email) {
        repository.register(username, password, email);
    }

    public LiveData<User> getLoginResult() {
        return loginResult;
    }

    public LiveData<String> getRegisterResult() {
        return registerResult;
    }
}